<% content_for :title do %>
  <%=h @edition.title %>
<% end %>

<% content_for :edit do %>
  <%= link_to 'Delete Entry?', 
              new_delete_request_path(:editable_id => @edition.id, 
                                      :editable_type => "Edition") %> |

  <% if session[:edit_mode] == false %>
    <%= link_to 'Edit This Page', edit_release_edition_path(@release, @edition) %> 
  <% else %>
    <%= link_to 'Finish Editing', release_edition_path(@release, @edition) %> 
  <% end %>
<% end %>

<table id="entry-table">

  <tr id="entry-table-row1">
    <td id="entry-top-pane">
      <span class="entry-title">
        <%=h @edition.title %>
      </span>

      <br />
      <span class="entry-title-sub">
	  by:
	  <% @release.artists.each_with_index do |artist, index| -%>
	    <span id="release-artist-<%= artist.id %>">
		   <%= (index == 0) ? "" : "&" %>
           <%= link_to artist.name, artist %>
           <span class="remove-artist">
             <%= link_to_remote 'x', :url => remove_release_artist_links_path(@release, :artist_id => artist.id), :method => :delete %>
		   </span>
        </span>
      <% end -%>
      <br />
      <%= link_to 'Add Artist', new_release_artist_link_path(@release),
                                :class => 'lightwindow',
                                :params => 'lightwindow_type=page,lightwindow_width=500,lightwindow_height=500' %>
      </span>
	  
	  
      <div id="top-tools">
        <% if @favorite.nil? %>
          <% if permitted_to? :create, :favorites %>
            <%= link_to 'Favorite', add_favorite_path(:id => @release.id,
                                                      :type => 'Release') %>
          <% end %>
        <% else %>
          <% if permitted_to? :destroy, :favorites %>
            <%= link_to 'Remove From Favorites', remove_favorite_path(:id => @favorite) %>
          <% end %>
        <% end %>
      </div><!-- /top-tools -->

    </td><!-- entry-top-pane -->
  </tr><!-- /entry-table-row1 -->

  <tr id="entry-table-row2">
    <td class="entry-left-pane">

      <div id="entry-left-image">
        <%= render :partial => 'images/image_viewer',
                   :locals => {:item => @edition,
                               :gallery_path => release_edition_images_path(@release, @edition) } %>
      </div><!-- /entry-left-image -->

	  <a href="#image-upload" class="lightwindow">Upload Image</a>
	  
	  <div id="image-upload" style="display: none">
	    <% form_for [@release, @edition], :html => {:multipart => true} do |form| %>
		
		  <% fields_for :images do |image_form| %>
		    <p>
            Image Upload: <%= image_form.file_field :image %><br />
            Type: <%= image_form.select :image_type, [ ['Photo'],
                                                       ['Logo'],
                                                       ['Cover'] ] %>
            <br />
            Description: <%= image_form.text_field :description %>		
		    </p>
	      <% end %>
		<% end %>
	  </div>

    </td><!-- /entry-left-pane -->

    <td class="entry-mid-pane">
      <table id="entry-mid-info">
        <% form_for [@release, @edition] do |form| %>

        <tr>
          <% form.fields_for :release do |f| %>
            <td class="entry-info-label">Type:</td>
            <td><%= f.select :release_type, Release::RELEASE_TYPES, :include_blank => true %></td>
          <% end %>
        </tr>

        <tr>
          <td class="entry-info-label">Catalog ID:</td>
          <td><%= form.text_field :catalogID, :size => 10 %></td>
        </tr>

        <tr>
          <td class="entry-info-label">Status:</td>
          <td><%= form.select :status, Edition::EDITION_STATUSES, :include_blank => true %></td>
        </tr>

		<tr>
          <td></td>
          <td>
            <%= form.submit "Apply Changes" %>
          </td>
        </tr>           
		<% end %>
		
		<tr>
		  <td class="entry-info-label">Dates:</td>
		  <td>
		    <div id="edition-dates">
				<%= render :partial => 'dates/dates',
						   :locals => { :dates => @edition.edition_dates,
										:item => @edition,
										:dates_url => edition_dates_url,
										:events => nil } %>
			</div>
		  </td>
		</tr>
		
		<tr>
          <td class="entry-info-label">Label:</td>
          <td>
		    <% if @edition.label %>
			  <%= link_to @edition.label.name, @edition.label %><br />
			  <%= link_to 'Change Label', new_edition_label_link_path(@edition),
			                              :class => 'lightwindow',
				  					      :params => 'lightwindow_type=page,lightwindow_width=500,lightwindow_height=500' %>
			  
			<% else %>
              <%= link_to 'Add Label', new_edition_label_link_path(@edition),
			                           :class => 'lightwindow',
				  					   :params => 'lightwindow_type=page,lightwindow_width=500,lightwindow_height=500' %>
			<% end %>
          </td>
        </tr>
		
        <tr>
          <td class="entry-info-label">Genre:</td>
          <td>
            <%= render :partial => 'genres/list_genres',
                       :locals => {:entry => @edition} %>
          </td>
        </tr>

      </table><!-- /entry-mid-info -->
    </tr><!-- /entry-table-row2 -->

    <tr id="entry-table-row2"> 
    <td class="entry-left-pane">
      <div id="entry-left-menu">
        <ul class="tabnav">
          <%= tab('Track Listing', 'track-pane', 'active') %>
          <%= tab('Info', 'info-pane', 'inactive') %>
          <%= tab('Versions', 'version-pane', 'inactive') %>
          <%= tab('Credits', 'credits-pane', 'inactive') %>
          <%= tab('Discuss', 'forum-pane', 'inactive') %>
          <%= tab('Reviews', 'review-pane', 'inactive') %>
        </ul>
      </div><!-- /entry-left-menu -->
    </td><!-- /entry-left-pane -->

    <td class="entry-mid-pane">
      <div id="entry-mid-content">

        <div id="track-pane">
          <%= render :partial => 'track_pane', :locals => {:release => @release, :edition => @edition} %>
        </div><!-- /track-pane -->

        <div id="info-pane" style="display: none">
          <h3>Information</h3>
          <% form_for [@release, @edition] do |form| %>
            <%= form.text_area :info, :rows => 10 %><br />
            <%= form.submit "Apply Changes" %>
          <% end %>
          <br />
      
          <div id="edit-history">
            <h3>Edit History</h3>
            <%= link_to 'Full History for This Page', release_edits_path(@edition) %>
          </div><!-- /edit-history -->

        </div><!-- /info-pane -->

        <div id="forum-pane"style="display: none">
          <h3><%=h @release.forum.title %></h3>  
          <%= render :partial => "forums/forum", 
                     :locals => {:forum => @release.forum} %>
        </div><!-- /forum-pane -->

        <div id="version-pane" style="display: none">
          <h3>Alternate Versions</h3>
          <%= link_to 'Add Edition', new_edition_path(:id => @release.id),
                                       :class => 'lightwindow',
                                       :params => 'lightwindow_type=page,lightwindow_height=500,lightwindow_width=500' %>
									   
		  <br /><br />

          <% @release.editions.each do |edition| %>
            <% next if edition.id == @edition.id %>

            <div class="release">
              <img src="/images/REDUX.jpg" alt="Album Art" width="100" height="100" />
              <%= link_to edition.title, release_edition_path(@release, edition) %>
              <br />
              Year: <br />
              Format: <br />
            </div><!-- /release -->
          <% end %>

        </div><!-- /version-pane -->

        <div id="review-pane" style="display: none">
          <h3>Reviews</h3>
            <%= render :partial => 'reviews/review', 
                       :locals => {:item => @release} %>
        </div><!-- /reviews -->

        <div id="credits-pane" style="display: none">
          <h3>Credits</h3>
          <%= link_to 'Add a Credit', new_edition_edition_credit_path(:edition_id => @edition.id),
                                      :class => 'lightwindow',
                                      :params => 'lightwindow_type=page,lightwindow_height=500,lightwindow_width=600' %>
		  <br /><br />

          <% @edition.edition_credits.each do |credit| -%>
            <%= render :partial => 'edit_edition_credit',
			           :locals => {:credit => credit} %>
          <% end -%>    
          <br />
        </div><!-- /credits -->

      </div><!-- /entry-mid-content -->
    </td>
  </tr>
</table>